# 一、创建字典的三种方式
# 1、第一种
info = {
    "stu1801":"ziqi",
    "stu1802":"zhaoming",
    "stu1803":"liuyu"
}
print(info)

# 2、第二种
# info_2020[key]=value
info_2020 = {}
info_2020["stu2020"] = "yunizizi"
print(info_2020)

# 3、第三种
info_03 = dict(stu1="李现",stu2="刘昊然")
print(info_03)

# 二、访问字典里的值
dict = {'name': 'zizi', 'age': 20}

print("dict['name']: ", dict['name'])
print("dict['age']: ", dict['age'])
print("dict['yuni']: ", dict['yuni'])

# 三、修改字典——增加
dict = {'name': 'zizi', 'age': 18}

dict['age'] = 20
dict['school'] = "中大南方"
print("dict['age']: ", dict['age'])
print("dict['school']: ", dict['school'])

# 四、修改字典——删
dict = {'name': 'zizi', 'age': 20}

del dict['name']  # 删除键 'name'
dict.clear()  # 清空字典
del dict  # 删除字典
info.popitem()  # 随机删除
print(info)
# 删
# info.pop("stu1803")
# print(info)
# 随机删
#info.popitem()
#print(info)

# 五、字典的嵌套——访问一个复杂的数据
FamousDict = {
    '薛之谦':{
      '身高':178,
      '体重':130,
      '口头禅':['我不要面子啊','你是神经病啊!']
    },
    '吴青峰':{
        '身高':170,
        '体重':120,
        '口头禅':['我叫吴青峰','你好']
    }
}
print(FamousDict["薛之谦"]["口头禅"][0])

# 六、迭代处理字典

found = {}
found ["a"]=0
found ["e"]=0
found ["o"]=0
found ["u"]=0
found ["f"]=0
print(found)
for kv in found:
    print(kv)


